#pragma once

#include <QAbstractItemView>
#include <QGridLayout>
#include <QListWidget>
#include <QPushButton>
#include <QTreeWidget>

#include "STreeWidget.h"
#include "widgets.h"

////////////////////////////////////////////////////////
//	下拉窗口，包含QTreeWidget和QPushButton
////////////////////////////////////////////////////////
class S_WIDGETS_EXPORT STreeComboWidget : public QListWidget {
  Q_OBJECT
 public:
  STreeComboWidget(QWidget* pPanent = nullptr, bool showInvert = true,
                   bool showFilterIndex = false, int itemHeight = 24,
                   int dropHeight = 168);

 public:
  void setTreeData(STreeData& treeData);
  void clearTreeData();
  void clearSelect();
  void setAutoDisappear();
  void showToolTip(int limitWidth);
  bool getSelectItemText(QStringList& lstText);
  const QStringList& getSelectItemData();

 protected:
  virtual bool eventFilter(QObject* watched, QEvent* event) override;

 protected Q_SLOTS:
  void onBtnClick();
  void onItemChange();
  void onFilterIndexClick(int index);

 Q_SIGNALS:
  void itemSelectChanged();
  void filterIndexSelectChanged(int index);

 private:
  STreeWidget* m_tree;       // 树控件
  QPushButton* m_btnInvert;  // 反选
  bool m_autoDisappear = false;
  bool m_showFilterIndex = false;
};
